package com.demo.security.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * jwt待验证token
 * @author molong
 * @since 2024/5/24
 */
public class JwtAuthenticationToken extends AbstractAuthenticationToken {


    /**
     * 原始访问令牌
     */
    private Token rawAccessToken;

    public JwtAuthenticationToken(Token unsafeToken) {
        super(null);
        this.rawAccessToken = unsafeToken;
        //未通过验证
        this.setAuthenticated(false);
    }

    @Override
    public Object getPrincipal() {
        return rawAccessToken;
    }

    @Override
    public void setAuthenticated(boolean authenticated) {
        super.setAuthenticated(authenticated);
    }

    @Override
    public boolean isAuthenticated() {
        return super.isAuthenticated();
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
        this.rawAccessToken = null;
    }
}
